#!/usr/bin/env bash


## create cluster
kubectl -n devops exec -it redis-cluster-0 -- redis-cli -a customer88. --cluster create --cluster-replicas 1 \
  $(kubectl -n devops get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.metadata.name}.redis-headless:6379 {end}')

## verify cluster
#kubectl -n devops exec -it redis-cluster-0 -- redis-cli -a customer88. --cluster check redis-cluster-0:6379 -a customer88.

## fix cluster
#kubectl -n devops exec -it redis-cluster-0 -- redis-cli --cluster fix redis-cluster-0:6379 -a customer88.

# FQDN  redis-cluster-0.redis-headless.devops.svc.cluster.local

for i in {0..5}; do
  kubectl -n devops exec -it redis-cluster-${i} -- /bin/bash /usr/local/bin/update-node.sh
done
